package common.components 
{
    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.filters.DropShadowFilter;
    
    import mx.controls.*;
    import mx.events.*;
    import mx.styles.CSSStyleDeclaration;
	
	[Bindable]
    public class ShadowBorderImage extends Image {

//        private var border:Sprite;
		
        public function ShadowBorderImage()
        {
            if (!this.styleDeclaration){
                this.styleDeclaration = new CSSStyleDeclaration();
            };
            
            this.styleDeclaration.defaultFactory = function ():void{
                this.verticalAlign = "middle";
                this.horizontalAlign = "center";
            };
            
            this.scaleContent = false;
            this.maintainAspectRatio = false;
//            this.addEventListener("updateComplete", onUpdateComplete);
//            this.addEventListener("complete", onComplete);
            this.addEventListener("initialize", onInit);
        }

//        private function onUpdateComplete(evt:Event):void
//        {
//            if (this.content != null){
//                if ((this.content is Bitmap)){
//                    Bitmap(this.content).smoothing = true;
//                };
//            };
//        }
        
        private function onInit(evt:Event):void
        {
//            this.border = new Sprite();
//            this.border.visible = false;
//            this.addChild(border);
            this.filters = [new DropShadowFilter(3, 85, 0, 0.8, 5, 5, 1, 2)];
        }
        
//        public function onComplete(evt:Event):void
//        {
//            this.border.visible = false;
//        }
        
//        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
//        {
//            super.updateDisplayList(unscaledWidth,unscaledHeight);
//            this.border.graphics.clear();
//            this.border.graphics.lineStyle(1, 16777215, 1);
//            var w:int = ((this.width - this.contentWidth) / 2);
//            var h:int = ((this.height - this.contentHeight) / 2);
//            
//            if (!isNaN(this.contentWidth))
//            {
//                this.border.graphics.drawRect(w-1, h-1, (this.contentWidth + 1), (this.contentHeight + 1));
//            };
//        }

	}
} 



